package com.edu.order.controller;


import com.edu.order.service.ITOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dingchengyu
 * @since 2022-05-13
 */
@RestController
@RequestMapping("order")
public class TOrderController {

    @Autowired
    private ITOrderService orderService;

    /**
     * 创建订单
     *
     * @param userId
     * @param commodityCode
     * @param count
     * @return
     */
    @RequestMapping("createOrder")
    public Long createOrder(@RequestParam("userId") Long userId,
                            @RequestParam("commodityCode") String commodityCode,
                            @RequestParam("count") int count) {
        return orderService.createOrder(userId, commodityCode, count);
    }

    /**
     * 创建错误订单
     *
     * @param userId
     * @param commodityCode
     * @param count
     * @return
     */
    @RequestMapping("createOrderError")
    public Long createOrderError(@RequestParam("userId") Long userId,
                            @RequestParam("commodityCode") String commodityCode,
                            @RequestParam("count") int count) {
        return orderService.createOrderError(userId, commodityCode, count);
    }

}
